home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000105_icon-group-sender _Wed Apr 27 08:48:03 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
2KB
Received: by cheltenham.cs.arizona.edu; Wed, 27 Apr 1994 09:01:12 MST
Date: Wed, 27 Apr 94 08:48:03 PDT
From: kwalker@sirtur.premenos.com (Ken Walker)
Message-Id: <9404271548.AA01384@sirtur.premenos.com>
To: icon-group@cs.arizona.edu
Subject: Re: tables, lists, and memory question
X-Sun-Charset: US-ASCII
Content-Length: 1871
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
> From: "Art Eschenlauer" <eschen@molbio.cbs.umn.edu>
>
>
> I've been wondering for some time now about how (if) Icon knows what
> things to trash.
Icon does its own storage management within the memory it malloc()s. When
it does not have room to allocate an object within the memory it has, it
performs a garbage collection to try to recover unused space before it
malloc()s more memory. To perform garbage collection, it starts from a
"basis" of locations that the Icon program can access, for example, the
program's variables, marking things that can be reached. For data types with
pointer semantics, it follows pointers until it reaches an end or reaches
something that has already been marked. When it has marked everything that
the program might use in the future, it can "free" everything else and
compact its allocated memory, relocating pointers to objects it moves.
Icon's garbage collection is not perfect, but it is conservative. It may
save a few things it doesn't need to. There is a rather subtle example.
If I remember correctly, it is something like:
procedure p()
local c
c := create write("Hi")
c := create write("Bye")
# do something that causes garbage collection
end
Internally, the second co-expression get a copy of the variable c with
a reference to the first co-expression even thought it doesn't use the
variable c. There is no way to activate the first co-expression, but
the garbage collector will save it. Dispite a few holes like this, the
Icon interpreter is pretty good about only keeping things that might still
be accessed by the Icon program. The Icon compiler is a little sloppier
about it. It may leave things in temporary variables that are no longer
needed and the garbage collector will assume that they are needed. However,
in practice this doesn't seem to be a problem.
Ken Walker, kwalker@premenos.com